﻿@using GrainManage.Web.Resources
@using GrainManage.Web.Common
@using GrainManage.Web.Helper
@model GrainManage.Web.Models.Account.SignInModel
@ScriptHelper.RSA()
<script type="text/javascript">
    $(document).ready(function () {
        $("#ImgVerificationCode").click(function (envent) {
            //$(this).attr("src", "/Handler/VerificationCode.ashx" + "?time=" + Math.random());
            $(this).attr("src", "/Image/ValidateCode" + "?time=" + Math.random());
        });
        //RsaCrypto.js中的方法
        bindFormEvent("#formLogin");
    });
</script>
<style type="text/css">
    #ImgVerificationCode {
        width: 80px;
        height: 26px;
        margin-top: 6px;
        vertical-align: top;
        cursor: pointer;
    }

    #VerificationCode {
        width: 55px;
        text-transform: uppercase;
    }

    .register a {
        color: blue;
        text-decoration: underline;
    }

    div.actions, div#footer {
        margin: 0px 0px 0px 32px;
    }
</style>

<div id="login-form">
    <div id="result" style="color: red">
        @AccountHelper.ShowStatus(ViewBag.Result)
    </div>
    @using (Html.BeginForm("SignIn", "Account", FormMethod.Post, new { @id = "formLogin" }))
    {
        @Html.AntiForgeryToken()       
        <div class="data">
            <ul>
                <li class="username">
                    @Html.LabelFor(m => m.UserName)
                    @Html.TextBoxFor(m => m.UserName, new { maxlength = 20 })
                    @Html.ValidationMessageFor(m => m.UserName)
                </li>
                <li class="password">
                    @Html.LabelFor(m => m.Password)
                    @Html.PasswordFor(m => m.Password)
                    @Html.ValidationMessageFor(m => m.Password)
                    @Html.HiddenFor(m => m.EncryptFlag)
                </li>
                <li class="verification-code">
                    @Html.LabelFor(m => m.VerificationCode)
                    @Html.TextBoxFor(m => m.VerificationCode, new { maxlength = 4 })
                    @*   @Html.Image("/Handler/VerificationCode.ashx", "ImgVerificationCode", AccountResx.VerificationCodeAlt)*@
                    @Html.Image("/Image/ValidateCode", "ImgVerificationCode", AccountResx.VerificationCodeAlt)
                    @Html.ValidationMessageFor(m => m.VerificationCode)
                </li>
                <li class="remember-me">
                    @Html.CheckBoxFor(m => m.RememberMe)
                    @Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
                </li>
            </ul>
        </div>

        <div class="actions">
            <input id="submit" type="submit" value="@AccountResx.SignIn"/>
        </div>
    }
    @AccountHelper.HidenRsaParameter()
</div>
<div id="footer">
    <span>@AccountResx.NoAccount</span>
    <span class="register">
        @Html.ActionLink(AccountResx.Register, "Login", new { actionName = "register" })
    </span>
</div>